﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using LinkCard.Utils;

namespace LinkCard.CustomerView.template.JobSearching.Master
{
    public partial class Default : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt;
            dt = DataHelper.SelectTable("SELECT IndustryName, IndustryID FROM Industrial  ORDER BY IndustryName", false);
            jobTitle.DataSource = dt;
            jobTitle.DataTextField = "IndustryName";
            jobTitle.DataValueField = "IndustryID";
            jobTitle.DataBind();
            jobTitle.Items.Insert(0, new ListItem("Ngành nghề", "0"));
            //
            dt = DataHelper.SelectTable("SELECT CityName, CityID FROM Cities  ORDER BY CityName", false);
            jobCity.DataSource = dt;
            jobCity.DataTextField = "CityName";
            jobCity.DataValueField = "CityID";
            jobCity.DataBind();
            jobCity.Items.Insert(0, new ListItem("Địa điểm", "0"));



            dt = DataHelper.SelectTable("Select Top 10 JobPosition, JobID, CompanyName from Jobs inner join Company on Jobs.CompanyID = Company.CompanyID where JobHot = 1 order by JobPostDate", false);
            rptBoxJobContent1.DataSource = dt;
            rptBoxJobContent1.DataBind();

            string sSQL = "Select count(jobID) totalJob, Industrial.IndustryID, IndustryName  from Industrial"
                            + " inner join Job_Industrial on Industrial.IndustryID = Job_Industrial.IndustryID "
                            + " group by Industrial.IndustryID, IndustryName order by totalJob desc";
            dt = DataHelper.SelectTable(sSQL, false);
            rptBoxJobContent2.DataSource = dt;
            rptBoxJobContent2.DataBind();

            dt = DataHelper.SelectTable("Select Top 10 JobPosition, JobID, CompanyName from Jobs inner join Company on Jobs.CompanyID = Company.CompanyID order by JobPostDate", false);
            rptBoxJobContent3.DataSource = dt;
            rptBoxJobContent3.DataBind();

            sSQL = "Select TOP 4 MsgTitle, MessageID, MsgLead, MsgHomeImage from message where IsHome = 1 order by MsgPostDate desc";
            dt = DataHelper.SelectTable(sSQL, false);
            rptTopJobFav.DataSource = dt;
            rptTopJobFav.DataBind();

            sSQL = "Select TOP 4 MsgTitle, MessageID, MsgLead, MsgHomeImage from message order by MsgPostDate desc";
            dt = DataHelper.SelectTable(sSQL, false);
            rptLeftNews.DataSource = dt;
            rptLeftNews.DataBind();

            
            

        }
    }
}